import type { AdColumn } from '@/components/AdVxeTable';

import { getRpcRequestSideEnumSchema } from '@/enums/iot/rpcRequestSideEnum';
import { useI18n } from '@/hooks/web/useI18n';

const rpcRequestSideEnumSchema = getRpcRequestSideEnumSchema();

const { t } = useI18n();

export const columns: AdColumn[] = [
  {
    title: t('entity.idTitle'),
    field: 'Id',
    width: 180,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'integer',
  },
  {
    title: t('iot.route.rpcLog.requestSideText'),
    field: 'RequestSide',
    width: 120,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'enum',
    enumData: rpcRequestSideEnumSchema,
  },
  {
    title: t('iot.route.rpcLog.requestIdText'),
    field: 'RequestId',
    width: 200,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('iot.route.rpcLog.clientIdText'),
    field: 'ClientId',
    width: 200,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('iot.route.rpcLog.methodText'),
    field: 'Method',
    width: 80,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('iot.route.rpcLog.argumentsText'),
    field: 'Arguments',
    width: 150,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'text',
    formCustomer: {
      colProps: {
        // span: 24,
        xs: 24, // <576px
        sm: 24, // ≥576px
        md: 24, // ≥768px
        lg: 24, // ≥992px
        xl: 24, // ≥1200px
        xxl: 24, // ≥1600px
        // xxxl: 24, // ≥2000px 3.0
      },
    },
  },
  {
    title: t('iot.route.rpcLog.succeededText'),
    field: 'Succeeded',
    width: 100,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'boolean',
    sortable: true,
  },
  {
    title: t('iot.route.rpcLog.messageText'),
    field: 'Message',
    width: 200,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'text',
    formCustomer: {
      colProps: {
        // span: 24,
        xs: 24, // <576px
        sm: 24, // ≥576px
        md: 24, // ≥768px
        lg: 24, // ≥992px
        xl: 24, // ≥1200px
        xxl: 24, // ≥1600px
        // xxxl: 24, // ≥2000px 3.0
      },
    },
  },
  {
    title: t('iot.route.rpcLog.resultText'),
    field: 'Result',
    width: 150,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'text',
    formCustomer: {
      colProps: {
        // span: 24,
        xs: 24, // <576px
        sm: 24, // ≥576px
        md: 24, // ≥768px
        lg: 24, // ≥992px
        xl: 24, // ≥1200px
        xxl: 24, // ≥1600px
        // xxxl: 24, // ≥2000px 3.0
      },
    },
  },
  {
    title: t('iot.route.rpcLog.createdTimeText'),
    field: 'CreatedTime',
    width: 180,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'datetime',
  },
  {
    title: t('iot.route.rpcLog.endedTimeText'),
    field: 'EndedTime',
    width: 180,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'datetime',
  },
  {
    title: t('iot.route.rpcLog.elapsedText'),
    field: 'Elapsed',
    width: 120,
    formVisible: true,
    formEditable: false,
    filterable: false,
    dataType: 'number',
  },
  {
    title: t('iot.route.rpcLog.deviceIdText'),
    field: 'DeviceId',
    width: 150,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'integer',
  },
  {
    title: t('iot.route.rpcLog.deviceNameText'),
    field: 'DeviceName',
    width: 200,
    formVisible: true,
    formEditable: false,
    filterable: true,
    filterIndex: 'Device.Name',
    dataType: 'string',
  },
];
